$(function () {
    listClassesMemberList(1);
    classesMemberCount();
   $('body')
       .on('click', '#btn1', function () { // 搜索
           listClassesMemberList(1);
   }).on('click','#not-approved',function () {
       icModale(0, '此学员尚未提交，无法批阅！');
   }).on('click','.openMarkTaskResult',function(){
       var that=$(this)
       openMarkTaskResult(that.data('user'),that.data('personaltask'))
   }).on('click','#btn2',function(){

       exportExecl.init({
           title:"销售记录数据导出",
           excelUrl: '/admin/classes/member/task/exportDataXls?taskId='+$("input[name='taskId']").val(),
           type:8
       })
   });
});

function openMarkTaskResult(userId,personalTaskId){
    parent.layer.open({
        type: 2,
        shadeClose: false,
        area:winArea,
        skin: 'layui-layer-demo',
        title: '批阅试卷',
        content: baseloaction+"/admin/classes/member/task/toMarkTaskPage?type=true&personalTaskId="+personalTaskId+"&userId="+userId
    });
}

/**
 * 加载班级数据
 * @param pageNo
 */
function listClassesMemberList(pageNo) {
    var params = $('#search-form').serializeJSON();
    params = JSON.stringify(params);
    var obj = {
        url: baseloaction + '/admin/classes/member/task/ajaxTaskRecordList',//请求URL
        contextId: 'user-list-context',//响应内容页面设置内容ID
        params: params,//请求参数
        pageNo: pageNo,//页码
        pageCall: listClassesMemberList, //分页回调加载数据(点击上下页时调用,该方法也在加载页面完成时调用)
        selectAllId: 'all-select',        //全选框ID
        callback: function () {
            $('#count').html('（共'+total+'名学员作业）');
        }
    };
    ajaxGetListData(obj);
}

/**
 * 加载班级数据
 * @param pageNo
 */
function classesMemberCount() {
    $.ajax({
        url:baseloaction +'/admin/classes/member/task/findStateCount',
        type:'post',
        dataType:'json',
        data:{
            'id':$("input[name='taskId']").val()
        },
        success:function (result) {

            $("#countSum").text(result.sumCount);
            $("#referCount").text(result.referCount);
            $("#notReferCount").text(result.sumCount -result.referCount);
            $("#haveReadCount").text(result.haveReadCount);
            $("#notHaveReadCount").text(result.sumCount-result.haveReadCount);
        },
        error:function (error) {
            icModale(0,'系统错误');
        }
    });
}
